#ifndef LIB_TWCORE_INTERNAL_TOASTWIDGET_H_
#define LIB_TWCORE_INTERNAL_TOASTWIDGET_H_

#include <QTimer>
#include <QLabel>
class QWidget;

namespace TWCore
{
	class ToastGenerator;
	class Toast : public QLabel
	{
		Q_OBJECT
		Q_DISABLE_COPY(Toast)
		Q_PROPERTY(int toastMaxWidth READ toastMaxWidth WRITE setToastMaxWidth)
		Q_PROPERTY(int marginX READ marginX WRITE setMarginX)
		Q_PROPERTY(int marginY READ marginY WRITE setMarginY)
		public:
			Toast(QWidget *parent,int toastIndex);
			~Toast();

			void show(const QString& msg,int x,int y,int duration);

			int toastMaxWidth()const {return i_toastMaxWidth;}
			void setToastMaxWidth(int w){i_toastMaxWidth = w;}
			int marginX()const {return i_marginX;}
			void setMarginX(int x){i_marginX = x;}
			int marginY()const {return i_marginY;}
			void setMarginY(int y){i_marginY = y;}
		private:
			static int i_toastMaxWidth;
			static int i_marginX;
			static int i_marginY;

			QTimer m_timer;
			int i_index;
		signals:
			void fadeOut(int);
		private slots:
			void timeout();
		friend class ToastGenerator;
	};
}

#endif /* LIB_TWCORE_INTERNAL_TOASTWIDGET_H_ */
